package com.wyvoid.forum.web.tag;

import com.wyvoid.forum.web.MyActionBeanContext;

import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * User: cjp
 * Date: 2007-7-3
 * Time: 21:17:47
 */
public class SecureAuthTag extends TagSupport {
    private String auth="";

    public void setAuth(String auth) {
        this.auth = auth;
    }

    public int doStartTag() throws JspException{
        MyActionBeanContext myActionBeanContext = new MyActionBeanContext((HttpServletRequest)pageContext.getRequest(),(HttpServletResponse)pageContext.getResponse());
        if(!myActionBeanContext.canAccess(auth)){
            return SKIP_BODY;
        }else{
            return EVAL_BODY_INCLUDE;
        }
    }
}
